package com.gz.web.datavalid.entity;

import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;

import javax.validation.constraints.NotNull;
import java.util.Date;

public class Monster {
    @NotEmpty//只适合于String、collection、map orarray，对于其他的不能为空用NotNull
    private String name;

    @NotNull(message = "age不能为空")
    @Range(min = 1, max = 100)
    private Integer age;

    @NotNull(message = "生日不能为空")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    @Override
    public String toString() {
        return "Monster{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", birthday=" + birthday +
                ", salary=" + salary +
                ", email='" + email + '\'' +
                '}';
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public float getSalary() {
        return salary;
    }

    public void setSalary(float salary) {
        this.salary = salary;
    }

    public Monster(String name, Integer age, Date birthday, float salary, String email) {
        this.name = name;
        this.age = age;
        this.birthday = birthday;
        this.salary = salary;
        this.email = email;
    }

    @NotNull(message = "salary不能为空")
    @NumberFormat(pattern = "###,###.##")
    private float salary;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Monster() {
    }

    public Monster(String name, Integer age, String email) {
        this.name = name;
        this.age = age;
        this.email = email;
    }

    @NotEmpty(message = "email不能为空")
    private String email;
}
